package com.zrrd.javaWeb.service;

import com.zrrd.javaWeb.bean.Tea;
import com.zrrd.javaWeb.dao.TeaDao;
import com.zrrd.javaWeb.utils.DBUtils;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

/**
 * @author WanJl
 * @version 1.0
 * @title TeaService
 * @description
 * @create 2024/1/22 10:21
 */
public class TeaService {
    private TeaDao teaDao=new TeaDao();

    /**
     * 查询所有
     * @return
     */
    public List<Tea> queryAll(){
        return teaDao.queryAll();
    }

    /**
     * 根据id查询
     * @param id
     * @return
     */
    public Tea queryOneById(Integer id){
        return teaDao.queryOneById(id);
    }

    /**
     * 插入
     * @param tea
     * @return
     */
    public int insert(Tea tea){
        return teaDao.insert(tea);
    }
    /**
     * 修改
     * @param tea
     * @return
     */
    public int update(Tea tea){
        Tea qt = teaDao.queryOneById(tea.getId());
        if (qt!=null){
            return teaDao.update(tea);
        }
        return 0;
    }

    /**
     * 根据id删除
     * @param id
     * @return
     */
    public int delete(Integer id){
        return teaDao.delete(id);
    }
}
